exports.sex = (val) => {
  switch (val) {
    case 1: {
      return "男";
    }
    case 2: {
      return "女";
    }
  }
};

exports.healthy = (val) => {
  switch (val) {
    case 1: {
      return "健康";
    }
    case 2: {
      return "良好";
    }
    case 3: {
      return "一般";
    }
    case 4: {
      return "较差";
    }
  }
};

exports.politicalStatus = (val) => {
  switch (val) {
    case 1: {
      return "中共党员";
    }
    case 2: {
      return "中共预备党员";
    }
    case 3: {
      return "共青团员";
    }
    case 4: {
      return "民革党员";
    }
    case 5: {
      return "民盟盟员";
    }
    case 6: {
      return "民建会员";
    }
    case 7: {
      return "民进会员";
    }
    case 8: {
      return "农工党党员";
    }
    case 9: {
      return "致公党党员";
    }
    case 10: {
      return "九三学社社员";
    }
    case 11: {
      return "台盟盟员";
    }
    case 12: {
      return "无党派人士";
    }
    case 13: {
      return "群众";
    }
  }
};

exports.fullTimeEducation = (val) => {
  const value = {
    1: "初中及以下",
    2: "中专",
    3: "高中",
    4: "大专",
    5: "大学",
    6: "研究生",
  };
  return value[val];
};

exports.jobEducation = (val) => {
  const value = {
    1: "其他",
    2: "大专",
    3: "大学",
    4: "研究生",
  };
  return value[val];
};

exports.isFamousTeacher = (val) => {
  switch (val) {
    case 1: {
      return "省级";
    }
    case 2: {
      return "市级";
    }
    case 3: {
      return "县级";
    }
    case 4: {
      return "否";
    }
  }
};

exports.isDownCadre = (val) => {
  switch (val) {
    case 1: {
      return "公务员";
    }
    case 2: {
      return "事业单位人员";
    }
    case 3: {
      return "其它人员";
    }
    case 4: {
      return "否";
    }
  }
};

exports.age = (val) => {
  const birthday = new Date(val.replace(/-/g, "/"));
  const d = new Date();
  const age =
    d.getFullYear() -
    birthday.getFullYear() -
    (d.getMonth() < birthday.getMonth() ||
    (d.getMonth() == birthday.getMonth() && d.getDate() < birthday.getDate())
      ? 1
      : 0);
  return age;
};

exports.organizationType = (val) => {
  const value = {
    1: "党委",
    2: "党总支",
    3: "党支部",
  };
  return value[val];
};

exports.state = (val) => {
  const value = {
    0: "待提交",
    1: "待审核",
    2: "审核通过",
    "-1": "已退回",
  };
  return value[val];
};

exports.status = (val) => {
  const value = {
    0: "待提交",
    1: "待审核",
    2: "已审核",
    "-1": "已退回",
  };
  return value[val];
};

exports.positionStatus = (val) => {
  const value = {
    0: "未发布",
    1: "发布中",
    3: "已结束",
    4: "已总结",
    "-1": "已中止",
  };
  return value[val];
};

exports.businessType = (val) => {
  const value = {
    1: "专业综合类",
    2: "党群活动类",
    3: "实践基地类",
    4: "教育基地类",
    5: "科普基地类",
  };
  return value[val];
};

exports.canHoldNum = (val) => {
  const value = {
    1: "20人以下",
    2: "20-50人",
    3: "50-100人",
    4: "100-200人",
    5: "200人以上",
  };
  return value[val];
};

exports.honorHierarchy = (val) => {
  const value = {
    1: "国家级",
    2: "市级",
    3: "县级",
  };
  return value[val];
};

exports.honorHierarchy1 = (val) => {
  const value = {
    1: "国家级",
    2: "省级",
    3: "市级",
    4: "县级",
    5: "镇级",
  };
  return value[val];
};

exports.coursewareType = (val) => {
  const value = {
    1: "视频",
    2: "音频",
    3: "图文",
    4: "文件",
  };
  return value[val];
};

exports.approvalStatue = (val) => {
  const value = {
    0: "待审核",
    1: "申请上线",
    2: "审核通过",
    3: "上线不通过",
    4: "申请修改",
    5: "修改通过",
    6: "修改不通过",
  };
  return value[val];
};

exports.coursewareType = (val) => {
  const value = {
    1: "视频",
    2: "音频",
    3: "图文",
    4: "文件",
  };
  return value[val];
};

exports.applyState = (val) => {
  const value = {
    1: "申请中",
    2: "已同意",
    3: "阵地取消",
    4: "组织取消",
    5: "已拒绝",
    6: "已结束",
  };
  return value[val];
};

exports.positionType = (val) => {
  const value = {
    1: "政治理论教育",
    2: "党性教育",
    3: "党的宗旨教育",
    4: "知识技能教育",
    5: "革命传统教育",
    6: "革命传统教育",
    7: "形势政策教育",
    8: "理想信念教育",
    9: "政治理论学习",
  };
  return value[val];
};

exports.formatDate = (val) => {
  const date = new Date(val);
  const YY = date.getFullYear() + "-";
  const MM =
    (date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1) + "-";
  const DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  const hh =
    (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
  const mm =
    (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
    ":";
  const ss =
    date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  return YY + MM + DD + " " + hh + mm + ss;
};

function padLeftZero(str) {
  return ("00" + str).substr(str.length);
}

exports.formatDate1 = (date, format) => {
  if (/(y+)/.test(format)) {
    format = format.replace(
      RegExp.$1,
      (date.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  }
  let o = {
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "h+": date.getHours(),
    "m+": date.getMinutes(),
    "s+": date.getSeconds(),
  };
  for (let k in o) {
    if (new RegExp(`(${k})`).test(format)) {
      let str = o[k] + "";
      format = format.replace(
        RegExp.$1,
        RegExp.$1.length === 1 ? str : padLeftZero(str)
      );
    }
  }
  return format;
};

exports.organizationTypes = (val) => {
  const value = {
    1: "党组织",
    2: "村(居)民委员会",
    3: "村(居)务监督委员会",
    4: "村(股份)经济合作社",
    5: "村(股份)经济合作社监督委员会",
  };
  return value[val];
};
